package com.ym.b2b.product.dao.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.ym.b2b.product.dao.EmBProductPromoDAO;
import com.ym.b2b.product.sqlbean.EmBProductPromo;
import com.zc.commons.base.Page;
import com.zc.commons.dao.ZcDao;

@Repository
public class EmBProductPromoDAOImpl<T> extends ZcDao<T> implements EmBProductPromoDAO {

    public Long searchPageEmBProductPromoNum(EmBProductPromo embproductpromo) throws DataAccessException {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("map", embproductpromo);
        return (Long) find("EM_B_PRODUCT_PROMO.searchPageEmBProductPromoNum", map);
    }

    public void searchPageEmBProductPromo(EmBProductPromo embproductpromo, Page<EmBProductPromo> page)
                                                                                                      throws DataAccessException {
        page.setTotalRow(searchPageEmBProductPromoNum(embproductpromo));
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("map", embproductpromo);
        map.put("startrow", page.getStartRow());
        map.put("pagesize", page.getPageSize());
        map.put("pageable", page.getPageable());
        page.setRows(list("EM_B_PRODUCT_PROMO.searchPageEmBProductPromo", map));
    }

    public void insertEmBProductPromo(EmBProductPromo record) throws DataAccessException {
        insert("EM_B_PRODUCT_PROMO.insertEmBProductPromo", record);
    }

    public int updateEmBProductPromo(EmBProductPromo record) throws DataAccessException {
        int rows = update("EM_B_PRODUCT_PROMO.updateEmBProductPromo", record);
        return rows;
    }

    public EmBProductPromo searchEmBProductPromo(EmBProductPromo emBProductPromo) throws DataAccessException {
        EmBProductPromo record = (EmBProductPromo) find("EM_B_PRODUCT_PROMO.searchEmBProductPromo", emBProductPromo);
        return record;
    }

    public int deleteEmBProductPromo(EmBProductPromo emBProductPromo) throws DataAccessException {

        int rows = delete("EM_B_PRODUCT_PROMO.deleteEmBProductPromo", emBProductPromo);
        return rows;
    }
}
